package top.vanchor.myblog2back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import top.vanchor.myblog2back.entity.BlogFeedback;
import top.vanchor.myblog2back.mapper.BlogFeedbackMapper;
import top.vanchor.myblog2back.service.IBlogFeedbackService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Ding
 * @since 2022-03-26
 */
@Service
public class BlogFeedbackServiceImpl extends ServiceImpl<BlogFeedbackMapper, BlogFeedback> implements IBlogFeedbackService {

    @Resource
    private BlogFeedbackMapper mapper;

    @Override
    public int toReport(BlogFeedback bean) {
        return mapper.insert(bean);
    }

    @Override
    public PageInfo<BlogFeedback> getList(Integer pageNo, Integer pageSize, Integer status) {
        PageHelper.startPage(pageNo,pageSize);
        return new PageInfo<>(mapper.getList(status));
    }

    @Override
    public void toDeal(BlogFeedback feedback) {
        QueryWrapper<BlogFeedback> wrapper = new QueryWrapper<>();
        wrapper.eq("feedback_id",feedback.getFeedbackId());
        mapper.update(feedback,wrapper);
    }
}
